package com.zero.guava.samples.EventBus;

import com.google.common.eventbus.EventBus;

/**
 * 创建EventBus并发送消息
 * 定义一个EventBus,先将上面的这个Listener类进行注册,通过Post方法即可向其发送消息
 */
public class SimpleEventBusExample {

    public static void main(String[] args) {

        EventBus eventBus = new EventBus();

        //注册Listener
        eventBus.register(new SimpleListener());
        System.out.println("post the simple event.");
        //向订阅者发送消息
        eventBus.post("Simple event");
    }
}
